package cn.hubujyjs.mooc.controller;


import cn.hubujyjs.mooc.common.Result;
import cn.hubujyjs.mooc.entity.Teacher;
import cn.hubujyjs.mooc.service.TeacherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 讲师 前端控制器
 * </p>
 *
 * @author Huang Jintao
 * @since 2022-11-15
 */
@RestController
@RequestMapping("/api/teacher")
@Api(tags = "讲师接口")
public class TeacherController {
    @Autowired
    private TeacherService teacherService;

    @ApiOperation("添加讲师")
    @PostMapping("/addTeacher")
    public Result addTeacher(@RequestBody Teacher teacher){
        teacherService.saveTeacher(teacher);
        return Result.success();
    }
    @ApiOperation("根据id获取讲师信息")
    @GetMapping("/getTeacherById/{id}")
    public Result<Teacher> getTeacherById(@PathVariable Long id){
        Teacher teacher=teacherService.getTeacherById(id);
        return Result.success(teacher);
    }
}

